<?php

    
    // 查询user表
    function get_user_data(){
        $result = mysql_query("SELECT * FROM user");
  
        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }

        $arrData = createJsonData($results);

        
    
        echo json_encode($arrData);
    }

    // 根据用户 name 或 tel 或 company 模糊搜索用户信息
    function search_user_data(){
        $result = mysql_query("select * from user , cv where concat(cv.name , cv.tel , cv.company) like 
        '%%$_POST[queryString]%%' and cv.openid = user.openid");

        $results = array();
        while ($row = mysql_fetch_assoc($result)) {
            $results[] = $row;
        }

        $arrData = createJsonData($results);
        echo json_encode($arrData);
   
   
    }

    


    // 添加 user 数据
    function insert_user_data(){
        mysql_query("insert into user 
        (head_img , openid , nick_name , last_login_time , 
        login_counts , gender , province , city , country) 
        values 
        ('$_POST[head_img]' , '$_POST[openid]' , '$_POST[nick_name]' , '$_POST[last_login_time]' , 
        '$_POST[login_counts]' , '$_POST[gender]' , '$_POST[province]' , '$_POST[city]' , '$_POST[country]')");
   
   
    }

    // 删除 user 数据
    function delete_user_data(){
        mysql_query("delete from user where openid='$_POST[openid]'");
    }



?>